<template>
  <UniDatetimePicker
    :type="type"
    :clear-icon="true"
    :border="getBorder"
    v-bind="getProps"
    @change="onChange"
  />
</template>

<script setup lang="ts">
  import UniDatetimePicker from '../uni_modules/uni-datetime-picker/uni-datetime-picker.vue';
  import { computed, type PropType } from 'vue';
  import { useFormItem } from '../hooks/useContext';

  defineProps({
    type: {
      type: String as PropType<'date' | 'daterange' | 'datetime' | 'datetimerange'>,
      default: 'date',
    },
  });

  const { getProps, setFormModel, formProps } = useFormItem({});

  const getBorder = computed(() => !formProps?.border);

  function onChange(val: string) {
    setFormModel(val);
  }
</script>

<style scoped></style>
